package servlet.hrf;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dao.hrf.ShopCartDAO;
import entity.ShopCart;

/**
 * Servlet implementation class DeleteGoods
 */
@WebServlet("/DeleteGoodss")
public class DeleteGoods extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		int id=Integer.parseInt(request.getParameter("id"));
		HttpSession session=request.getSession();
		List<ShopCart> list=(List<ShopCart>) session.getAttribute("list");
		for(int i=0;i<list.size();i++){
			if(list.get(i).getId()==id){
				list.remove(i);
				session.setAttribute("list", list);
			}
		}
		request.getRequestDispatcher("ShopCart.jsp").forward(request, response);
	}
}
